package Cinema.CinemaEntities;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import Cinema.DataLayer.IXmlParsable;


/**
 * Represents a site with only one theater(hall).
 * @author The Fuchtzeinsoft Team.
 *
 */
public class SmallSite extends Site implements IXmlParsable {

	private Theater myTheater;

	@Override
	public Set<Theater> getTheaters() {
		Set<Theater> theater = new HashSet<Theater>() {

			private static final long serialVersionUID = 1L;

			@Override
			public boolean add(Theater t) {
				if (this.isEmpty()) {
					return super.add(t);
				}
				return false;
			}

			@Override
			public boolean addAll(Collection<? extends Theater> c) {
				if (this.isEmpty()) {
					if (c.size() == 1) {
						return super.addAll(c);
					} else {
						return false;
					}
				}
				return false;
			}
		};
		theater.add(myTheater);
		return theater;
	}

	/**
	 * creates a new small site
	 * @param theater  - is the one theater that in the small site.
	 */
	public SmallSite(Theater theater) {
		super(theater.getName(), theater.getLocation(), theater.getCity());
		myTheater = theater;
	}


}
